import request from '@/utils/request'

// 查询考勤列表
export const getAttendancesList = (params) => {
  return request({
    url: '/attendances',
    params
  })
}

// 根据用户id和月份查询已归档的考勤明细  获取考勤详情
export const getAtteArchiveDetail = (data) => {
  return request({
    url: `/attendances/archive/${data.userId}/${data.yearMonth}`
  })
}

// 上传考勤打卡数据
export const importAttendance = (file) => {
  return request({
    url: '/attendances/import',
    method: 'post',
    file
  })
}

// 根据部门id查询考勤设置
export const attendanceSettingByDepartId = (data) => {
  return request({
    url: '/cfg/atte/item',
    method: 'post',
    data
  })
}

// 根据部门id查询请假规则设置
export const holidayRuleByDepartId = (data) => {
  return request({
    url: '/cfg/leave/list',
    method: 'post',
    data
  })
}

// 根据部门id查询考勤扣款规则
export const payOffByDepartId = (data) => {
  return request({
    url: '/cfg/ded/list',
    method: 'post',
    data
  })
}

// 根据部门id查询考勤加班规则
export const overTimeByDepartId = (data) => {
  return request({
    url: '/cfg/extDuty/item',
    method: 'post',
    data
  })
}

// 编辑用户的考勤记录
export const updateAttendance = (data) => {
  return request({
    url: `/attendances/${data.userId}`,
    method: 'put',
    data
  })
}
// 归档历史列表
export const getArchivingList = (params) => {
  return request({
    url: '/attendances/reports/year',
    params
  })
}
// 通过归档历史ID   查询归档详情
export const getArchivingCont = (params) => {
  return request({
    url: `/attendances/reports/${params.id}`,
    params
  })
}

// 月度考勤记录归档
export const archives = (params) => {
  return request({
    url: '/attendances/archives',
    params
  })
}

// 新建考勤报表
export const newReports = (params) => {
  return request({
    url: '/attendances/newReports',
    params
  })
}

// 获取月考勤报表数据
export const reportFormList = (params) => {
  return request({
    url: '/attendances/reports',
    params
  })
}

// 保存或者更新请假规则
export const leaveSave = (data) => {
  return request({
    url: '/cfg/leave',
    method: 'put',
    data
  })
}

// 保存考勤扣款规则
export const deductionsSave = (data) => {
  return request({
    url: '/cfg/deduction',
    method: 'put',
    data
  })
}

// 保存加班规则
export const overtimeSave = (data) => {
  return request({
    url: '/cfg/extDuty',
    method: 'put',
    data
  })
}

// 保存考勤设置
export const attendanceSave = (data) => {
  return request({
    url: '/cfg/atte',
    method: 'put',
    data
  })
}

// 文件上传
export const fileUpdate = (data) => {
  return request({
    url: `/employees/archives/${data.month}`,
    method: 'put',
    data
  })
}
